package com.bango.flex{
	import flash.utils.Dictionary;
	
	import spark.components.TextArea;

	public class BangoAgent{
		
		public static var _bangoAgent:BangoAgentImpl = new BangoAgentImpl();
		
		/**
		 * Gets the current logging level value.
		 * 
		 * @param logEvents
		 * 		The value to set the current level, this could be a combination of more levels by using the OR operator. 
		 * 		Example:
		 * 			BangoAgent.LoggingLevel = BangoLoggingLevel.LEVEL_1 | BangoLoggingLevel.LEVEL_3
		 * 		This will enable both level 1 and 3
		 */
		public static function set loggingLevel(level:Number):void{
			_bangoAgent.loggingLevel = level;
		}
		
		/**
		 * Gets the current logging level value.
		 * 
		 * @return the current logging level value.
		 */
		public static function get loggingLevel():Number{
			return _bangoAgent.loggingLevel;
		}
		
		/**
		 * Used to set the events avaible for a level
		 * 
		 * @param level
		 * 		The level to set, like BangoLoggingLevel.LEVEL_1
		 * @param events
		 * 		An array of string from BangoSessionEvents.EVENT_*
		 */
		public static function setLoggingLevelEvents(level:Number,events:Array):void{
			_bangoAgent.setLoggingLevelEvents(level,events);
		}
		
		/**
		 * Gets whether not events are being logged.
		 * 
		 * @return Whether not events are being logged.
		 */
		public static function get logEnabled():Boolean{
			return _bangoAgent.logEnabled;
		}
		
		/**
		 * Enables or disables the logging of events.
		 * 
		 * @param logEvents
		 *            Should events be logged.
		 */
		public static function set logEnabled(logEvents:Boolean):void{
			_bangoAgent.logEnabled = logEvents ;
		}
		
		/**
		 * Gets whether or not database connections are persistent.
		 * 
		 * @return Whether or not database connections are persistent.
		 */
		public static function get persistDatabaseConnection():Boolean{
			return _bangoAgent.persistDatabaseConnection;
		}
		
		/**
		 * Enables or disables the persistence of database connections.
		 * 
		 * @param persistConn
		 *            Should database connection remain open.
		 */
		public static function set persistDatabaseConnection(persistConn:Boolean):void{
			_bangoAgent.persistDatabaseConnection = persistConn;
		}
		
		/**
		 * Gets Whether or not should be used the offline database.
		 * 
		 * @return Whether or not should be used the offline database.
		 */
		public static function get useOfflineStorage():Boolean{
			return _bangoAgent.useOfflineStorage;
		}
		
		/**
		 * Enables or disables the use of the offline database.
		 * 
		 * @param useOff
		 *            Should database connection remain open.
		 */
		public static function set useOfflineStorage(useOff:Boolean):void{
			_bangoAgent.useOfflineStorage = useOff;
		}
		
		/**
		 * Gets the application version to be used.
		 * 
		 * @return The application version to be used.
		 */
		public static function get applicationVersion():String{
			return _bangoAgent.applicationVersion;
		}
		
		/**
		 * The application version to be used, if this is not supplied then the
		 * application version number of the application is used.
		 * 
		 * @param applicationVersion
		 *            The application version to be used.
		 */
		public static function set applicationVersion(applicationVersion:String):void{
			_bangoAgent.applicationVersion = applicationVersion;
		}
		
		/**
		 * Gets the unique identifier for the user of the application
		 * 
		 * @return The unique identifier for the user.
		 */
		public static function get userId():String{
			return _bangoAgent.userId;
		}
		
		/**
		 * The unique identifier that you have for the user of the application. For
		 * example, this could be an email or a GUID or just a numerical value.
		 * 
		 * @param userId
		 */
		public static function set userId(userId:String):void{
			_bangoAgent.userId = userId;
		}
		
		/**
		 * Gets the URL to post the data to.
		 * 
		 * @return The URL to post the data to.
		 */
		public static function get postURL():String{
			return _bangoAgent.postURL;
		}
		
		/**
		 * The URL to post the data to.
		 * 
		 * @param postURL
		 *            The URL to post the data to.
		 */
		public static function set postURL(postURL:String):void{
			_bangoAgent.postURL = postURL;
		}
		
		/**
		 * Gets the type of application.
		 * 
		 * @return The type of application, for example "Lite"
		 */
		public static function get applicationType():String{
			return _bangoAgent.applicationType;
		}
		
		/**
		 * The type of application.
		 * 
		 * @param appType
		 *            The type of application, for example "Lite".
		 */
		public static function set applicationType(appType:String):void{
			_bangoAgent.applicationType = appType;
		}
		
		/**
		 * Gets the method used to distribute the application.
		 * 
		 * @return The method used to distribute the application, for example
		 *         "AppStore".
		 */
		public static function get applicationChannel():String{
			return _bangoAgent.applicationChannel;
		}
		
		/**
		 * The method used to distribute the application.
		 * 
		 * @param appChannel
		 *            The method used to distribute the application, for example
		 *            "AppStore".
		 */
		public static function set applicationChannel(appChannel:String):void{
			_bangoAgent.applicationChannel = appChannel;
		}
		
		
		/**
		 * Gets the maximum number of events a profile can hold, default is 50. 
		 * Breaking a profile is important to avoid big requests to the server
		 * 
		 * @return the number of maximum events for each profile.
		 * 
		 */
		
		public static function get maximumEventsPerProfile():Number
		{
			return _bangoAgent.maximumEventsPerProfile;
		}
		
		/**
		 * Sets the maximum number of events a profile can hold, default is 50. 
		 * Breaking a profile is important to avoid big requests to the server
		 * 
		 * @param maxEvents
		 *            The number of maximum events
		 * 
		 */
		public static function set maximumEventsPerProfile(maxEvents:Number):void
		{
			_bangoAgent.maximumEventsPerProfile = maxEvents;
		}

		
		/**
		 * Gets whether or not an attempt should be made to discover the user’s
		 * location.
		 * 
		 * @return Whether or not an attempt should be made to discover the user’s
		 *         location.
		 */
		public static function get findLocation():Boolean{
			return _bangoAgent.findLocation;
		}
		
		/**
		 * Sets whether or not an attempt should be made to discover the user’s
		 * location.
		 * 
		 * @param findLoc 
		 * 			Whether or not an attempt should be made to discover the user’s
		 *          location.
		 */
		public static function set findLocation(findLoc:Boolean):void{
			_bangoAgent.findLocation = findLoc;
		}
		
		/**
		 * Whether events will be posted on end session
		 * @return Whether events will be posted on end session
		 */
		public static function get postOnEndSession():Boolean{
			return _bangoAgent.postOnEndSession;
		}
		
		/**
		 * Whether events will be posted on end session
		 * @param postOnEndSess Set whether events will be posted on end session
		 */
		public static function set postOnEndSession(postOnEndSess:Boolean):void{
			_bangoAgent.postOnEndSession = postOnEndSess;
		}
		
		/**
		 * Gets the current device version.
		 * 
		 * @return the current device verson.
		 */
		public static function get deviceVersion():String
		{
			return _bangoAgent.deviceVersion;
		}
		
		/**
		 * Change the device version that will be sent 
		 * @param version Set the device version
		 */
		public static function set deviceVersion(version:String):void
		{
			_bangoAgent.deviceVersion = version;
		}
		
		/**
		 * Gets the current device version.
		 * 
		 * @return the current device verson.
		 */
		public static function get operatingSystemVersion():String
		{
			return _bangoAgent.operatingSystemVersion;
		}
		
		/**
		 * Change the device version that will be sent 
		 * @param osVersion Set the device operating system version
		 */
		public static function set operatingSystemVersion(osVersion:String):void
		{
			_bangoAgent.operatingSystemVersion = osVersion;
		}
		
		/**
		 * Gets the current device operating system.
		 * 
		 * @return the current device operating system.
		 */
		public static function get operatingSystem():String
		{
			return _bangoAgent.operatingSystem;
		}
		
		/**
		 * Change the device operating system that will be sent 
		 * @param os Set the device operating system
		 */
		public static function set operatingSystem(os:String):void
		{
			_bangoAgent.operatingSystem = os;
		}
		
		/**
		 * Gets the current product.
		 * 
		 * @return the current product.
		 */
		public static function get product():String
		{
			return _bangoAgent.product;
		}
		
		/**
		 * Change the product that will be sent 
		 * @param product Set the product
		 */
		public static function set product(product:String):void
		{
			_bangoAgent.product = product;
		}
		
		/**
		 * Gets the current device model.
		 * 
		 * @return the current device model.
		 */
		public static function get deviceModel():String
		{
			return _bangoAgent.deviceModel;
		}
		
		/**
		 * Change the device model that will be sent 
		 * @param model Set the device model
		 */
		public static function set deviceModel(model:String):void
		{
			_bangoAgent.deviceModel = model;
		}
		
		/**
		 * Gets the current device make.
		 * 
		 * @return the current device make.
		 */
		public static function get deviceMake():String
		{
			return _bangoAgent.deviceMake;
		}
		
		/**
		 * Change the device make that will be sent 
		 * @param make Set the device make
		 */
		public static function set deviceMake(make:String):void
		{
			_bangoAgent.deviceMake = make;
		}
		/**
		 * Gets the current device brand.
		 * 
		 * @return the current device brand.
		 */
		
		public static function get deviceBrand():String
		{
			return _bangoAgent.deviceBrand;
		}
		
		/**
		 * Change the device brand that will be sent 
		 * @param brand Set the device brand
		 */
		public static function set deviceBrand(brand:String):void
		{
			_bangoAgent.deviceBrand = brand;
		}
		
		/**
		 * Send the logged events to Bango
		 */
		public static function postEvents():void{
			_bangoAgent.postEvents();
		}
		
		/**
		 * Initiates logging, this must be called after the configuration methods
		 * but before any other logging or any other session methods.
		 * 
		 * @param applicationKey
		 *            The ApplicationId that has been set up for the application
		 *            using the management tools.
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
	 	 * @param eventDetail
	 	 *            Optional. Any extra detail that you would like to attach to the event.
	 	 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 * 
		 */
		public static function startSession(applicationKey:String, eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null):void{
			_bangoAgent.startSession(applicationKey, eventValue,eventDetail,eventParameters);
		}
		
		/**
		 * Indicates that the session has ended after the app has been reduced and sends the events to the server.
		 * 
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
		 * @param eventDetail
		 *            Optional. Any extra detail that you would like to attach to the event.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function endSession(eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null):void{
			_bangoAgent.endSession(eventValue,eventDetail,eventParameters);
		}
		
		
		/**
		 * Indicates that the session has ended and the app has been closed. If on android sends the data to the server.
		 * 
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
		 * @param eventDetail
		 *            Optional. Any extra detail that you would like to attach to the event.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function closeApplication(eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null):void{
			_bangoAgent.closeApplication(eventValue,eventDetail,eventParameters);
		}
		
		/**
		 * Logs a generic event.
		 * 
		 * @param eventName
		 *            The event name is identifier for the type of event that you
		 *            would like to record. You can create your own event names
		 *            simply sending it in this field.
		 * @param eventDetail
		 *            Optional. Any extra detail that you would like to attach to the event.
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function onEvent(eventName:String,eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null):void{
			_bangoAgent.onEvent(eventName,eventValue,eventDetail,eventParameters);
		}
		
		/**
		 * Logs an onDemandVideoStart event.
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
		 * @param eventDetail
		 *            Optional. Any extra detail that you would like to attach to the event.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function onDemandVideoStart(eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null):void{
			_bangoAgent.onDemandVideoStart(eventValue,eventDetail,eventParameters);
		}
		
		/**
		 * Logs an onDemandVideoStop event.
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
		 * @param eventDetail
		 *            Optional. Any extra detail that you would like to attach to the event.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function onDemandVideoStop(eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null):void{
			_bangoAgent.onDemandVideoStop(eventValue,eventDetail,eventParameters);
		}
		
		/**
		 * Logs an onLiveVideoStart event.
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
		 * @param eventDetail
		 *            Optional. Any extra detail that you would like to attach to the event.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function onLiveVideoStart(eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null ):void{
			_bangoAgent.onLiveVideoStart(eventValue,eventDetail,eventParameters);
		}
		
		/**
		 * Logs an onLiveVideoStop event.
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
		 * @param eventDetail
		 *            Optional. Any extra detail that you would like to attach to the event.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function onLiveVideoStop(eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null):void{
			_bangoAgent.onLiveVideoStop(eventValue,eventDetail,eventParameters);
		}
		
		/**
		 * Indicates that the session has entered an idle state, for example the
		 * application has lost focus.
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
		 * @param eventDetail
		 *            Optional. Any extra detail that you would like to attach to the event.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function onIdle(eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null):void{
			_bangoAgent.onIdle(eventValue,eventDetail,eventParameters);
		}
		
		/**
		 * Indicates that the session has resumed after an idle state, for example
		 * the application has gained focus after losing focus.
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
		 * @param eventDetail
		 *            Optional. Any extra detail that you would like to attach to the event.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function onResume(eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null):void{
			_bangoAgent.onResume(eventValue,eventDetail,eventParameters);
		}
		
		/**
		 * Logs a search event.
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
		 * @param eventDetail
		 *            Optional. Any extra detail that you would like to attach to the event.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function onSeach(eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null):void{
			_bangoAgent.onSeach(eventValue,eventDetail,eventParameters);
		}
		
		/**
		 * Increments the page view count.
		 * @param eventValue
		 *            Optional. This is a value that you can associate with the event.
		 * @param eventDetail
		 *            Optional. Any extra detail that you would like to attach to the event.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function onPageView(eventValue:String = "",eventDetail:String = "",eventParameters:Dictionary = null):void{
			_bangoAgent.onPageView(eventValue,eventDetail,eventParameters);
		}
		
		/**
		 * Logs an error event.
		 * 
		 * @param errorId
		 *            The id you want to assign to the error.
		 * @param errorClass
		 *            The class the error occurred in.
		 * @param message
		 *            Any extra detail that you would like to attach to the error.
		 * @param eventParameters
		 *            Optional. A hashtable collection of event parameters.
		 */
		public static function onError(message:String,errorId:String, errorClass:String,eventParameters:Dictionary = null):void{
			_bangoAgent.onError(message,errorId,errorClass,eventParameters);
		}
		
		/**
		 * Gets the JSON Text of the current post profile.
		 * 
		 * @return The JSON Text of the current post profile.
		 */	
		public static function viewBatch():String{
			return _bangoAgent.viewBatch();
		}
		
		
		
		public static function debug(str:String):void{
			_bangoAgent.debug(str);
		}
		
		public function get debugArea():TextArea{
			return _bangoAgent.debugArea;
		}
		
		public function set debugArea(value:TextArea):void{
			_bangoAgent.debugArea = value;
		}
		
	}
}